package com.mikao.dao;

import com.mikao.entity.Address;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

public interface AddressDao extends JpaRepository<Address, Long>, JpaSpecificationExecutor {

    /**
     * 根据用户ID和是否为默认的状态查找地址列表
     *
     * @param userId ID
     * @return list
     */
    List<Address> findAllByUserIdAndIsSelected(Long userId, Boolean isSelected);

    /**
     * 根据用户ID获取地址列表
     *
     * @param userId 用户ID
     * @return list
     */
    List<Address> findAllByUserIdOrderByCreateTimeDesc(Long userId);
}
